import pika, sys

credentials = pika.PlainCredentials("guest", "guest")
conn_params = pika.ConnectionParameters("localhost",credentials = credentials)
conn_broker = pika.BlockingConnection(conn_params)

channel = conn_broker.channel()
channel.exchange_declare(exchange="durable-exchange",
                         exchange_type="direct",
                         passive=False,
                         durable=True,
                         auto_delete=False)
channel.queue_declare(queue="durable-queue",durable=True)
channel.queue_bind(queue="durable-queue",
                   exchange="durable-exchange",
                   routing_key="hola")

msg_props = pika.BasicProperties()
msg_props.content_type = "text/plain" 
msg_props.delivery_mode = 2

channel.basic_publish(body="durable_message",
                      exchange="durable-exchange",
                      properties=msg_props,
                      routing_key="hola")
